package jp.tkym.labs.store;

import jp.tkym.labs.store.TableMeta.ColumnMeta;

/**
 * Sql String Generator
 * @author kazunari
 */
class DDLStatementGenerator{
	String create(TableMeta p){
		StringBuilder sb = new StringBuilder();
		sb.append("create table ");
		sb.append(p.tableName());
		sb.append(" (");
		boolean first = true;
		for(ColumnMeta column : p.columns()){
			if(first) first = false;
			else sb.append(", ");
			sb.append(column.name);
			sb.append(" ");
			sb.append(column.type);
		}
		sb.append(")");
		return sb.toString();
	}
	
	String drop(TableMeta p){
		StringBuilder sb = new StringBuilder();
		sb.append("drop table ");
		sb.append(p.tableName());
		return sb.toString();
	}
	
	String truncate(String tableName){
		return "truncate table "+tableName;
	}
}